<template>
	<view class="detailall">
	<!-- 	//navbar头部 -->
		<navbar left-text="退后" right-text="收藏" @clickLeft="goleft()">
			<view class="na-all" @click="clickrighttext">
				<view class="lleft" >
					<image class="lleft" src="/static/tabBar/share.png" mode=""></image>
				</view>

			</view>
		</navbar>
		<!-- 个人详细数据 -->
		<!-- 教师要求 -->
		<view class="content-all">
			<!-- 顶部标题 -->
			<view class="contenttit">
				<view class="">
					<image class="smallico" src="../../static/tabBar/youxiu.png" mode=""></image>
				</view>
				<view class="">
					{{detail_tea.name}}指导师信息
				</view>
			</view>
			<view style="padding-left: 30rpx;">
				<image style="width: 200rpx;" :src="detail_tea.img" mode="widthFix"></image>
			</view>
			<view class="" >
				<view class="content-cont" >
					<view class="cont-left">
						编号: <text class="texttitlecontent">JTZDSID-{{detail_tea.id}}</text>
					</view>
				</view>
				<view class="content-cont" >
					<view class="cont-left">
						性别要求:
						 <text class="texttitlecontent">{{detail_tea.sex}}</text>
					</view>
				</view>
				<view class="content-cont" >
					<view class="cont-left">
						联系方式:
						 <text class="texttitlecontent">{{detail_tea.tel}}</text>
					</view>
				</view>
				<view class="content-cont" >
					<view class="cont-left">
						教育经历:<text class="texttitlecontent">{{detail_tea.content}}</text>
					</view>
				
				</view>
				<view class="content-cont" >
					<view class="cont-left">
						专业领域:
						 <text class="texttitlecontent">{{detail_tea.profession}}</text>
					</view>
				
				</view>
				
			</view>
		</view>
		
		<view class="intro">
			<view class="contenttit" >
				<view class="">
					<image class="smallico" src="../../static/tabBar/jianjie.png" mode=""></image>
				</view>
				<view class="">
					教育理念:
				</view>
			</view>
			<view class="intro-content">
				{{detail_tea.educationalidea}}
			</view>
		</view>
		
		<view class="intro">
			<view class="contenttit" >
				<view class="">
					<image class="smallico" src="../../static/tabBar/jianjie.png" mode=""></image>
				</view>
				<view class="">
					工作经验:
				</view>
			</view>
			<view class="intro-content">
				{{detail_tea.profile}}
			</view>
		</view>
		
		<view class="intro">
			<view class="contenttit" >
				<view class="">
					<image class="smallico" src="../../static/tabBar/jianjie.png" mode=""></image>
				</view>
				<view class="">
					相关证书
				</view>
			</view>
			<view class="intro-content">
				<image src="../../static/img/tutordetail/RJ8eH20YQkGZ0RE7vuaCjSGyobmc1VIzywSRLuPL.jpg" mode="widthFix"></image>
			</view>
		</view>
		
		<!-- 预约此单 -->
		<view class="" v-if="showbutton">
			<button @click="goform" >预约指导师</button>
		</view>
		<!-- 分享按钮阴影 -->
		<view v-if="isShow" class="reserva-detal" @touchmove.stop.prevent="">
			<!-- 阴影框 -->
			<view class="pop-mask" @tap="hidePop()">
			</view>
			<view class="pop-box" :animation="animationData">
				<view class="pop-btitle">
					<view class="pop-item">
						<view class="" v-for="(item,index) in list" :key="item.id" @click="gosharelist(item.id)">
							<image style="width: 100rpx;height: 100rpx;padding:30rpx 50rpx;" :src="item.img" mode=""></image>
							<view class="pop-item-title">
								{{item.title}}
							</view>
						</view>
						
					</view>
				</view>
		
				<view class="pop-sub" @tap="gocancel">
					取消
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import navbar from '@/components/uni/uni-nav-bar/uni-nav-bar.vue'
	import mline from '@/components/common/Lines.vue'
	import {
		mapState
	} from 'vuex';
	import $http from '@/common/api/request.js'
	export default {
		data() {
			return {
				baseurl:"https://zyc618.mynatapp.cc",
				has_tea_static:false,//是否有指导师
				keyid:0,
				detail_tea:{},//接收教师的信息
				stu_detail:{},
				isShow: false,
				animationData: {}, //动画过渡
				list:[{id:0,title:"微信好友",img:"../../static/tabBar/weixin.jpg"},
					{id:1,title:"微信朋友圈",img:"../../static/tabBar/friend.jpg"},
					{id:2,title:"微信收藏",img:"../../static/tabBar/linka.jpg"},
					{id:3,title:"新浪微博",img:"../../static/tabBar/weibo.jpg"},
					{id:4,title:"QQ",img:"../../static/tabBar/qq.jpg"},
					{id:5,title:"商品二维码",img:"../../static/tabBar/shop.jpg"},
				],
				showbutton:false
			};
		},
		components: {
			navbar,mline
		},
		methods:{
			online(){
			},
			//点击退后的按钮
			goleft(){
				uni.navigateBack({
					delta:1
				})
			},
			goform(){
				uni.showModal({
					title:"预约指导师?",
					content:`确认预约${this.detail_tea.name}指导师`,
					
					success:(res)=> {
						if (res.confirm) {
						      // 用户点击了确定按钮->发起请求:
							  if(this.has_tea_static){
								  
								  this.postrelation()
							  }else{
								  uni.showToast({
								  	title:"已经存在指导师了,之后预约只会更新",
									icon:"none"
								  })
							  }
						      
						    } else if (res.cancel) {
						      // 用户点击了取消按钮
						      console.log('用户点击了取消按钮');
						    }
					}
				})
				// uni.navigateTo({
				// 	url:"/pages/VIPcustom/VIPcustom"
				// })
			},
			//点击分享按钮:
			clickrighttext() {
				this.isShow = true;
			},
			//点击取消按钮
			gocancel(){
				this.isShow=false
			},
			//分享框的显示隐藏
			hidePop() {
				var animation = uni.createAnimation({
					duration: 200,
				})
				animation.translateY(0).step()
				this.animationData = animation.export()
				setTimeout(() => {
					animation.translateY(600).step()
					this.isShow = false;
				}, 200)
			
			},
			//点击分享的按钮:
			gosharelist(index){
				if(index === 0){
					this.shareall("weixin","WXSceneSession")
				}else if(index === 1){
					this.shareall("weixin","WXSceneTimeline")
				}else if(index === 2){
					this.shareall("weixin","WXSceneFavorite")
				}else if(index === 3){
					this.shareall("sinaweibo","")
				}else if(index === 4){
					this.shareall("qq","")
				}else if(index === 5){
					this.shareall("weixin","WXSceneSession")
				}
				
			},
			//分享的函数功能:
			shareall(provider,scene){
				uni.share({
					provider:provider,
					type: 0,
					scene: scene,
					title: `这个家教${this.stu_detail.class}${this.stu_detail.science}你心动吗?`,
					summary: `我正在看${this.stu_detail.situation}，赶紧跟我一起来体验！`,
					href: `https://static-mp-226e15e0-3338-4b4a-a504-1a5766808d99.next.bspapp.com/#/pages/tutordetail/tutordetail?keyid=${this.keyid}`,
					imageUrl: "https://zyc618.mynatapp.cc/images/index/%E6%95%A3%E5%85%B51.jpg",
					success: function(res) {
						uni.showTabBar({
							title: "分享成功"
						})
					},
					fail: function(err) {
						console.log("fail:" + JSON.stringify(err));
					}
				})
			},
			//发起请求tea与stu关系:
			postrelation(){
				$http.request({
					url: "/save/postrelation",
					method:'POST',
					header:{
						token:true
					},
					data:{
						userid:this.userInfo.id,
						teacherid:this.detail_tea.id
					}
				}).then((res) => {
					console.log(res);
					
				}).catch(() => {
					uni.showToast({
						title: "获取数据失败",
						icon: "error",
						mask: true,
						duration: 2000
					})
				})
			},
			findtea(){
				$http.request({
					url: "/save/findteach",
					method:'POST',
					header:{
						token:true
					},
				}).then((res) => {
					
					if(res.code == 200){
						
						this.has_tea_static = true;
						
					}else{
						uni.showToast({
							title:res.msg,
							icon:"none",
							duration:1200
						})
						this.has_tea_static = false;
						if(this.my_teacherid !== res.tea_id){
							this.showbutton = true
						}
						
					}
					
				}).catch(() => {
					uni.showToast({
						title: "获取数据失败",
						icon: "error",
						mask: true,
						duration: 2000
					})
				})
			},
			getteacher(index){///save/getteacher
				$http.request({
					url: "/save/getteacher",
					method:'POST',
					header:{
						token:true
					},
					data:{
						teacherid:index
					}
				}).then((res) => {
					
					this.detail_tea = res.data;
					this.detail_tea.img = this.baseurl + this.detail_tea.img
					
				}).catch(() => {
					uni.showToast({
						title: "获取数据失败",
						icon: "error",
						mask: true,
						duration: 2000
					})
				})
			}
		},
		onLoad(e) {
			this.findtea();
			//我的页面进去的
			if(e.hasOwnProperty("tea_id")){
				this.my_teacherid = e.tea_id;
				this.getteacher(e.tea_id);
			}
			if(e.hasOwnProperty("itemdetail")){
				this.detail_tea = JSON.parse(e.itemdetail);
			}
			
		},
		//计算属性:
		computed: {
			...mapState({
				userInfo: state => state.user.userInfo
			})
		},
	}
</script>

<style lang="scss">
	.detailall{
		background-color: #f8f8f8
	}
	.tableclass{
		margin: 40rpx 0;
		
		table {
		      width: 100%;
		      border: 1px solid black;
		      margin: 0 auto;
		      border-collapse: collapse;
		  }
		.tabletop{
			background-color: #cfcfcf;
		}
		  td {
		      height: 50px;
				width: 10%;
		      border: 1px solid black;
		      text-align: center;
		      vertical-align: center;
		  }
			
		  .trmorning {
		      background-color: #fffef2;
		  }
				.trafter {
				    background-color: #eff9fe;
				}
				.trnight {
				    background-color: #fef3f7;
				}
	}
	  .tic{
		  .tic-title{
			  color: #309de0;
			  font-size: 26rpx;
		  }
		  .tic-content{
			  padding: 10rpx;
		  }
	  }
	.na-all {
		width: 100%;
		display: flex;
		
		align-items: center;
		position: relative;
		.lleft {
			width: 40rpx;
			height: 40rpx;
			position: absolute;
			right: 0;
			top: 10rpx;
		}

		.rright {
			width: 40rpx;
			height: 40rpx;
		}
	}
	.detail-top{
		display: flex;
		.imgtitle-t{
			margin: 30rpx;
			overflow: hidden;
			width: 20%;
			height: 150rpx;
			background-color: #309de0;
			border-radius: 100rpx;
			.imgtitle{
				width: 100%;
				height: 150rpx;
				border-radius: 100rpx;
			}
		}
		.detail-top-c{
			width: 75%;
			.c-name{
				color: #309de0;
				font-weight: 500;
				margin-top: 30rpx;
			}
			.c-review{
				display: flex;
				justify-content: space-around;
				width: 100%;
				.c-review-item{
					display: flex;
					
					.c-review-it{
						text-align: center;
						.c-review-it-t{
							
						}
						.c-review-it-b{
							color: #309de0;
						}
				}
				.rigbording{
					border-right: 1rpx solid #cfcfcf;
					height: 60rpx;
					padding: 10rpx 20rpx;
				}
				}
				
			}
		}
		
	}
	.detai-but{
		color: #FFFFFF;
		border-radius: 10rpx;
		display: flex;
		padding: 5rpx 20rpx;
		.button-all{
			width: 95%;
			.butleft{
				font-size: 24rpx;
			background-color: #309de0;
			margin-right: 10rpx;
		}
		.butright{
			font-size: 24rpx;
			background-color: #ffbb17;
		}
		}
		
	}
	.content-all{
		margin-top: 20rpx;
		background-color: #FFFFFF;
		font-size: 28rpx;
		.content-cont{
			display: flex;
			padding: 20rpx 20rpx;
				.cont-left{
					width: 100%;
					display: flex;
					
					
					.texttitlecontent{
						color:#9c446e;
						padding-left: 20rpx;
						width: 80%;
						font-weight: 600;
					}
				}
				.cont-right{
					
				}
		}
	}
	.intro{
		margin-top: 30rpx;
	}
	.contenttit{
		color: #309de0;
		display: flex;
		align-items: center;
		padding: 0 20rpx;
		height: 100rpx;
		margin-top: 30rpx;
		background-color: #FFFFFF;
	
		.smallico{
			width: 40rpx;
			height: 40rpx;
			margin-right: 10rpx;
		}
	}
	.intro-content{
		text-indent: 32.4px;
		padding: 10rpx 30rpx;
		background-color: #FFFFFF;
		margin-bottom: 20rpx;
		font-size: 28rpx;
		font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
	}
	.tic{
			padding: 20rpx 20rpx;
		.tic-title{
			
		}
		
	}
	.reserva-detal {
		position: fixed;
		left: 0;
		top: 0;
		width: 100%;
		height: 100%;
		z-index: 999;
	
		.pop-mask {
			position: absolute;
			left: 0;
			top: 0;
			width: 100%;
			height: 100%;
			background-color: rgba(0, 0, 0, .6);
		}
	
		.pop-box {
			position: absolute;
			left: 0;
			bottom: 0;
			width: 100%;
			background-color: #ffffff;
			border-radius: 30rpx;
	
			.pop-btitle {
				height: 450rpx;
				.pop-item{
					display: flex;
					flex-wrap: wrap;
					justify-content: center;
					align-items: center;
					.pop-item-title{
						display: flex;
						justify-content: center;
						align-items: center;
					}
				}
			}
	
	
			.pop-sub {
				z-index: 9999;
				line-height: 80rpx;
				text-align: center;
				margin-bottom: 120rpx;
			}
		}
	}
</style>